package com.dingwei.lesyndrome.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;

import com.dingwei.lesyndrome.R;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created time 2018/3/7.
 * Creator 南柯一梦丶 on
 * Personal signature 余生还长 何必慌张
 * Page description :
 */

public class NewsSearchActivity extends BaseActivity {
    @Bind(R.id.edt_keyword)
    EditText edtKeyword;
    @Bind(R.id.tv_cancell)
    TextView tvCancell;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_news_search;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        edtKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    String keyword = edtKeyword.getText().toString().trim();
                    if (!TextUtils.isEmpty(keyword)) {
                        Intent intent = new Intent(getApplicationContext(), NewsSearchListActivity.class);
                        intent.putExtra("keywords", keyword);
                        startActivity(intent);
                    }
                }
                return false;
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.tv_cancell)
    public void onViewClicked() {
        finish();
    }
}
